//
//  EFGoodsDetailViewCellTitle.m
//  EnjogFood
//
//  Created by guocheng on 2017/5/21.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFGoodsDetailViewCellTitle.h"
#import "EFGoodsDetailViewItemTitle.h"

@interface EFGoodsDetailViewCellTitle()

@property(strong,nonatomic)UILabel* titleLabel;

@end

@implementation EFGoodsDetailViewCellTitle


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor whiteColor];
        [self initView];
    }
    return self;
}

-(void)setObject:(EFGoodsDetailViewItemTitle *)item{
    [self.titleLabel setText:item.title];
    [self.titleLabel sizeToFit];
}

+(CGFloat)cellHeight:(EFGoodsDetailViewItemTitle *)item{
    CGFloat height = 45;
    
    UILabel *tempLabel = [[UILabel alloc] init];
    tempLabel.font = [UIFont systemFontOfSize:13];
    tempLabel.numberOfLines = 0;
    tempLabel.text = item.title;
    
    tempLabel.width = kScreenWidth - 2*20;
    [tempLabel sizeToFit];
    
    CGFloat labelHeight = tempLabel.height;
    
    return height + labelHeight;
}

-(void)initView{
    [self.contentView addSubview:self.titleLabel];
}

-(UILabel *)titleLabel{
    if(_titleLabel == NULL){
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 40, 0)];
        _titleLabel.font = [UIFont systemFontOfSize:17];
        _titleLabel.textColor  = kBlack333;
        _titleLabel.numberOfLines = 0;
        _titleLabel.left = 20;
        _titleLabel.top = 18;
    }
    return _titleLabel;
}

@end
